<template>
  <div>
    <div v-for="(item,index) in dataList" :key="index">
      <!-- 三张图显示样式 -->
      <div class="cityItems" v-if="item.images.length >= 3">
        <div class="title">
          <nuxt-link :to="`/post/detail?id=${item.id}`">{{item.title}}</nuxt-link>
        </div>
        <nuxt-link :to="`/post/detail?id=${item.id}`">
          <p class="content">{{item.summary}}</p>
        </nuxt-link>
        <!-- <el-row></el-row> -->
        <nuxt-link :to="`/post/detail?id=${item.id}`">
          <el-row class="imgs" justify="space-between" type="flex">
            <img :src="item.images[0]" alt />
            <img :src="item.images[1]" alt />
            <img :src="item.images[2]" alt />
          </el-row>
        </nuxt-link>
        <el-row type="flex" justify="space-between" align="middle" class="urseItem">
          <el-row class="bottom" type="flex" align="middle">
            <span>
              <i class="el-icon-location-outline"></i>
              {{item.cityName}}
            </span>
            <div class="haha">
              <el-row type="flex" align="middle">
                by
                <img :src="item.account.defaultAvatar" alt class="touxiang" />
                <span class="userName">{{item.account.nickname}}</span>
                <span>
                  <i class="el-icon-view"></i>
                  {{item.watch}}
                </span>
              </el-row>
            </div>
          </el-row>
          <span class="zang">{{item.like || 0}}赞</span>
        </el-row>
      </div>

      <!-- 一张图样式 -->
      <div class="cityItemsTwo" v-else>
        <el-row type="flex">
          <nuxt-link :to="`/post/detail?id=${item.id}`">
            <div class="left">
              <img :src="item.images[0]" alt v-if="item.images.length" />
              <img src="@/assets/tuijan.png" alt v-else />
            </div>
          </nuxt-link>
          <el-col class="right">
            <div class="title">
              <nuxt-link :to="`/post/detail?id=${item.id}`">{{item.title}}</nuxt-link>
            </div>
            <nuxt-link :to="`/post/detail?id=${item.id}`">
              <p class="content">{{item.summary}}</p>
            </nuxt-link>
            <el-row type="flex" justify="space-between" align="middle" class="urseItem xia">
              <el-row class="bottom" type="flex" align="middle">
                <span>
                  <i class="el-icon-location-outline"></i>
                  {{item.cityName}}
                </span>
                <div class="haha">
                  <el-row type="flex" align="middle">
                    by
                    <img :src="item.account.defaultAvatar" alt class="touxiang" />
                    <span class="userName">{{item.account.nickname}}</span>
                    <span>
                      <i class="el-icon-view"></i>
                      {{item.watch}}
                    </span>
                  </el-row>
                </div>
              </el-row>
              <span class="zang">{{item.like ||0}}赞</span>
            </el-row>
          </el-col>
        </el-row>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    dataList: {
      type: Array,
      default: {}
    }
  },
  methods: {
    toPage(id) {
      this.$router.push({
        path: "/post/detail",
        query: {
          id: id
        }
      });
    }
  }
};
</script>

<style lang="less" scoped>
.cityItems,
.cityItemsTwo {
  padding: 20px 0;
  border-bottom: 1px solid #ddd;
  .title {
    //   height: 24px;
    font-size: 18px;
    font-weight: normal;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 1;
    margin-bottom: 20px;
    &:hover{
        color: #ffa705;
    }
  }
  .content {
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    font-size: 14px;
    color: #666;
  }

  .imgs {
    padding: 20px 0;
    & > img {
      width: 220px;
    }
  }
  .urseItem {
    .haha {
      padding: 0 10px;
    }
    .bottom {
      font-size: 12px;
      color: #ababab;
      .touxiang {
        width: 16px;
        height: 16px;
        border-radius: 50%;
        padding: 0 5px;
      }
      .userName {
        color: #ffa705;
        margin-right: 10px;
      }
    }
    .zang {
      font-size: 16px;
      color: #ffa705;
    }
  }
  .left {
    //   height: 220px;
    width: 220px;
    img {
      //   height: 220px;
      width: 220px;
    }
  }
  .right {
    padding-left: 10px;
    .xia {
      margin-top: 15px;
    }
  }
}
</style>